//
//  QEditChargeCell.m
//  QoilPublic
//
//  Created by 杨凯 on 16/8/17.
//  Copyright © 2016年 杨凯. All rights reserved.
//

#import "QEditChargeCell.h"

@implementation QEditChargeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.moneyLabel.font = [UIFont boldSystemFontOfSize:20.0];
}

- (void)setStyle:(QEditChargeCellStyle)style{

    _style = style;
    if(_style == QEditChargeCellStylePayout){//支出
        _moneyLabel.textColor = [QColorUtility defaultRedColor];
    }else if (_style == QEditChargeCellStyleIncome){//收
        _moneyLabel.textColor = [UIColor colorWithRed:38/255.0 green:199/255.0 blue:132/255.0 alpha:1];
    }
}

- (void)setIndexPath:(NSIndexPath *)indexPath{
    _indexPath = indexPath;
    if(_indexPath.row == 0){
        _moneyLabel.hidden = NO;
        _iconImageView.hidden = YES;
        _iconTitleLabel.hidden = YES;
    }else if (_indexPath.row == 1){
        _moneyLabel.hidden = YES;
        _iconImageView.hidden = NO;
        _iconTitleLabel.hidden = NO;
    
    }else if (_indexPath.row == 2){
        _moneyLabel.hidden = YES;
        _iconImageView.hidden = NO;
        _iconTitleLabel.hidden = NO;
    }
}

- (void)setTypeStr:(NSString *)typeStr{
    _typeStr = typeStr;
    if(_style == QEditChargeCellStylePayout){//支出
        if(_indexPath.row == 1){
              self.iconTitleLabel.text = _typeStr;
            NSString *s;
            NSArray *arr = [_typeStr componentsSeparatedByString:@"-"];
            if(arr.count){
                s = arr[0];
            }
            if([s isEqualToString:@"工程费用"]){
                self.iconImageView.image = [UIImage imageNamed:@"gcCharge_image"];
            }else if ([s isEqualToString:@"业务费用"]){
                self.iconImageView.image = [UIImage imageNamed:@"ywCharge_image"];
            }else if ([s isEqualToString:@"个人费用"]){
                self.iconImageView.image = [UIImage imageNamed:@"mySelfCharge_image"];
            }
        }
    }else if (_style == QEditChargeCellStyleIncome){//收
        if(_indexPath.row == 1){
              self.iconTitleLabel.text = _typeStr;
            if([_typeStr isEqualToString:@"工程款"]){
                self.iconImageView.image = [UIImage imageNamed:@"moneyCharge_image"];
            }else if ([_typeStr isEqualToString:@"租金"]){
                self.iconImageView.image = [UIImage imageNamed:@"zCharge_image"];
            }else if([_typeStr isEqualToString:@"赔付款"]){
                self.iconImageView.image = [UIImage imageNamed:@"pCharge_image"];
            }else if([_typeStr isEqualToString:@"分红"]){
                self.iconImageView.image = [UIImage imageNamed:@"fCharge_image"];
            }else if([_typeStr isEqualToString:@"其他"]){
                self.iconImageView.image = [UIImage imageNamed:@"other_image"];
            }
        }
    }
}

- (void)setMoneyStr:(NSString *)moneyStr{
    _moneyStr = moneyStr;
    if(_style == QEditChargeCellStylePayout){//支出
        if(_indexPath.row == 2){
              self.iconTitleLabel.text = _moneyStr;
            if([_moneyStr isEqualToString:@"现金"]){
                self.iconImageView.image = [UIImage imageNamed:@"xMoney_image"];
            }else if ([_moneyStr isEqualToString:@"会员余额"]){
                self.iconImageView.image = [UIImage imageNamed:@"yMoney_image"];
            }else if([_moneyStr isEqualToString:@"信用卡"]){
                self.iconImageView.image = [UIImage imageNamed:@"creditcard_image"];
            }
        }
    }else if (_style == QEditChargeCellStyleIncome){//收
        if(_indexPath.row == 2){
            self.iconTitleLabel.text = _moneyStr;
            if([_moneyStr isEqualToString:@"现金"]){
                self.iconImageView.image = [UIImage imageNamed:@"xMoney_image"];
            }else if ([_moneyStr isEqualToString:@"会员余额"]){
                self.iconImageView.image = [UIImage imageNamed:@"yMoney_image"];
            }else if([_moneyStr isEqualToString:@"信用卡"]){
                self.iconImageView.image = [UIImage imageNamed:@"creditcard_image"];
            }
        }
    }
}

- (void)setMoneys:(NSString *)moneys{

    _moneys = moneys;
    if(_moneys.length > 0){
        _moneyLabel.text = _moneys;
    }else{
        _moneyLabel.text = @"0.00";

    }
}


@end
